<!DOCTYPE html>

<html lang="en" data-content_root="../../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>Testing &#8212; Pytch  documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
    <link rel="stylesheet" type="text/css" href="../../_static/classic.css?v=36340f97" />
    <link rel="stylesheet" type="text/css" href="../../_static/css/pytch-classic.css?v=0321735e" />
    
    <script src="../../_static/documentation_options.js?v=7f41d439"></script>
    <script src="../../_static/doctools.js?v=9bcbadda"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <link rel="icon" href="../../_static/favicon.ico"/>
    <link rel="author" title="About these documents" href="../../about.html" />
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Project storage as zipfile" href="zipfile-format.html" />
    <link rel="prev" title="Tutorials" href="tutorials.html" /> 
  </head><body>
<div class="NavBar">
  <a href="../../../app/"><h1>Pytch</h1></a>
  <ul>
    <a href="https://pytch.scss.tcd.ie/"><li>About Pytch</li></a>
    <a href="../../index.html"><li>Help</li></a>
    <a href="../../../app/tutorials/"><li>Tutorials</li></a>
    <a href="../../../app/my-projects/"><li>My projects</li></a>
  </ul>
</div>
<div class="warning-work-in-progress">
  <p>These help pages are incomplete — we are working on it!</p>
</div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="testing">
<h1>Testing<a class="headerlink" href="#testing" title="Link to this heading">¶</a></h1>
<section id="unit-tests">
<h2>Unit tests<a class="headerlink" href="#unit-tests" title="Link to this heading">¶</a></h2>
<p>A few portions of the codebase have unit tests.  You can launch a
process which runs these tests, watching for changes and re-running,
using the command</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>npm<span class="w"> </span>run<span class="w"> </span>mocha
</pre></div>
</div>
</section>
<section id="integration-tests">
<h2>Integration tests<a class="headerlink" href="#integration-tests" title="Link to this heading">¶</a></h2>
<p>These are performed using <a class="reference external" href="https://www.cypress.io/">Cypress</a>.  Once
a <a class="reference internal" href="../../build-tools/makesite/development-local-server.html#local-development-server"><span class="std std-ref">local development server</span></a> is
running, the Cypress UI can be launched with:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>./node_modules/.bin/cypress<span class="w"> </span>open
</pre></div>
</div>
<p>By default Cypress looks for the server at <code class="docutils literal notranslate"><span class="pre">localhost:3000</span></code>, which
is where <code class="docutils literal notranslate"><span class="pre">npm</span> <span class="pre">start</span></code> listens.</p>
<p>Note that you will also need some supporting local webservers running
for the Cypress tests:</p>
<ul class="simple">
<li><p><strong>Skulpt files</strong> must be available at <code class="docutils literal notranslate"><span class="pre">localhost:8124</span></code>.  This
webserver is provided by the <code class="docutils literal notranslate"><span class="pre">dev-server.sh</span></code> script within the
<code class="docutils literal notranslate"><span class="pre">pytch-build</span></code> repo.</p></li>
<li><p><strong>Tutorial files</strong> must be available at <code class="docutils literal notranslate"><span class="pre">localhost:8125</span></code>.  This
webserver is also provided by the <code class="docutils literal notranslate"><span class="pre">dev-server.sh</span></code> script within
the <code class="docutils literal notranslate"><span class="pre">pytch-build</span></code> repo.</p></li>
<li><p><strong>Demo zipfiles</strong> must be available at <code class="docutils literal notranslate"><span class="pre">localhost:8126</span></code>.  Because
this feature is experimental, this webserver must be started
manually.  See the <code class="docutils literal notranslate"><span class="pre">README</span></code> within the <code class="docutils literal notranslate"><span class="pre">tools</span></code> directory of the
<code class="docutils literal notranslate"><span class="pre">pytch-demos</span></code> repo for more information.</p></li>
</ul>
</section>
<section id="testing-a-deployment-zipfile">
<span id="testing-zipfile-with-cypress"></span><h2>Testing a deployment zipfile<a class="headerlink" href="#testing-a-deployment-zipfile" title="Link to this heading">¶</a></h2>
<p>To test a <a class="reference internal" href="../../build-tools/makesite/making-deployment-zipfile.html#making-deployment-zipfile"><span class="std std-ref">deployment zipfile</span></a>, the
base URL for Cypress to use for testing can be overridden on the
command line.  For example, if you are using the provided
<a class="reference internal" href="../../build-tools/makesite/testing-deployment-zipfile.html#testing-deployment-zipfile"><span class="std std-ref">Docker-based mechanism for serving a deployment
zipfile</span></a>, then a command along the lines
of</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nv">CYPRESS_BASE_URL</span><span class="o">=</span>http://localhost:5888/beta/g112233445566/app/<span class="w"> </span>./node_modules/.bin/cypress<span class="w"> </span>open
</pre></div>
</div>
<p>will launch the interactive Cypress UI, and</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nv">CYPRESS_BASE_URL</span><span class="o">=</span>http://localhost:5888/beta/g112233445566/app/<span class="w"> </span>./node_modules/.bin/cypress<span class="w"> </span>run
</pre></div>
</div>
<p>will run the Cypress tests in headless mode from the command line.</p>
<p>For copy/paste convenience, these command-lines are written to stdout
by the <code class="docutils literal notranslate"><span class="pre">serve-zipfile.sh</span></code> script, as outlined in the documentation
for the <a class="reference internal" href="../../build-tools/makesite/testing-deployment-zipfile.html#testing-deployment-zipfile"><span class="std std-ref">Docker-based mechanism for serving a deployment
zipfile</span></a>.</p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper"><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../user/index.html">Using the Pytch web app</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../vm/user/index.html">Writing Pytch programs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../about.html">About Pytch</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contact.html">Contact</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../developer.html">Developer documentation</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../developer/development-setup.html">Development setup</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../developer/design-overview.html">Design overview</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../vm/developer/index.html">VM</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="index.html">Webapp</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="index.html#top-level-routes">Top-level routes</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="index.html#individual-aspects-of-design">Individual aspects of design</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../medialib/developer/index.html">Media library</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../developer/index.html">Website</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../build-tools/index.html">Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../source-build.html">Source and build information</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../releases/changelog.html">Changelog</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../legal/index.html">Legal information</a></li>
</ul>
<div class="docs-home-link"><hr>
  <ul>
    <li>
      <a href="../../index.html">Pytch help home</a>
    <li>
  </ul>
</div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
  </body>
</html>